package com.zretc.support.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.stereotype.Component;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * @Description
 * @Author jiaminxxi
 * @Date 2020-07-28 11:47:35
 */

@Component
@Entity
@Table(name = "question")
public class Question implements Serializable {

    private static final long serialVersionUID = 261611786105088360L;

    /**
     * 问题编号
     */
    @Id
    @Column(name = "questionId")
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long questionId;

    /**
     * 问题标题
     */
    @Column(name = "questionTitle")
    private String questionTitle;

    /**
     * 问题内容
     */
    @Column(name = "questionContent")
    private String questionContent;

    /**
     * 用户编号
     */

    @ManyToOne
    @JoinColumn(name = "userId")
    @NotFound(action= NotFoundAction.IGNORE)
    private User user;

    /**
     * 问题时间
     */
    @Column(name = "questionDate")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date questionDate;

    @Column(name = "questionStatus")
    private Integer questionStatus;

    @Transient
    private Long hotQuestion;


    @Override
    public String toString() {
        return "Question{" +
                "questionId=" + questionId +
                ", questionTitle='" + questionTitle + '\'' +
                ", questionContent='" + questionContent + '\'' +
                ", user=" + user +
                ", questionDate=" + questionDate +
                '}';
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Question(Long questionId, String questionTitle, String questionContent, User user, Date questionDate) {
        this.questionId = questionId;
        this.questionTitle = questionTitle;
        this.questionContent = questionContent;
        this.user = user;
        this.questionDate = questionDate;
    }

    public Question() {
    }

    public Long getQuestionId() {
        return this.questionId;
    }

    public void setQuestionId(Long questionId) {
        this.questionId = questionId;
    }

    public String getQuestionTitle() {
        return this.questionTitle;
    }

    public void setQuestionTitle(String questionTitle) {
        this.questionTitle = questionTitle;
    }

    public String getQuestionContent() {
        return this.questionContent;
    }

    public void setQuestionContent(String questionContent) {
        this.questionContent = questionContent;
    }

    public Date getQuestionDate() {
        return this.questionDate;
    }

    public void setQuestionDate(Date questionDate) {
        this.questionDate = questionDate;
    }

    public Integer getQuestionStatus() {
        return questionStatus;
    }

    public void setQuestionStatus(Integer questionStatus) {
        this.questionStatus = questionStatus;
    }

    public Long getHotQuestion() {
        return hotQuestion;
    }

    public void setHotQuestion(Long hotQuestion) {
        this.hotQuestion = hotQuestion;
    }
}
